package com.sayyi.demo.micro.order.service.impl;

import com.sayyi.demo.micro.order.entity.OrderTbl;
import com.sayyi.demo.micro.order.mapper.OrderTblMapper;
import com.sayyi.demo.micro.order.service.OrderSagaService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("orderSagaService")
@Slf4j
public class OrderSageServiceImpl implements OrderSagaService {

    @Autowired
    private OrderTblMapper orderTblMapper;

    @Override
    public int createOrder(OrderTbl orderTbl) {
        log.info("创建订单[{}]", orderTbl);
        orderTblMapper.insert(orderTbl);
        return orderTbl.getId();
    }

    @Override
    public void removeOrder(int id) {
        log.info("回滚创建订单[{}]", id);
        orderTblMapper.deleteById(id);
    }
}
